package com.cn.yang.util;//package com.cn.yang.util;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@WebFilter("/*")
//public class MyFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest req = (HttpServletRequest) servletRequest;
//        HttpServletResponse resp = (HttpServletResponse) servletResponse;
//        req.setCharacterEncoding("UTF-8");
//        resp.setCharacterEncoding("UTF-8");
//
//
//        String url = req.getServletPath();
//        if (url.startsWith("/back/")){
//            if(url.endsWith("css")||url.endsWith("js")||url.endsWith("regester")){
//                filterChain.doFilter(servletRequest,servletResponse);
//            }else {
//                String username = (String) req.getSession().getAttribute("username");
//                if (username==null){
//                    resp.sendRedirect("/login.html");
//                }else {
//                    filterChain.doFilter(servletRequest,servletResponse);
//                }
//            }
//        }else {
//            filterChain.doFilter(servletRequest,servletResponse);
//        }
////        filterChain.doFilter(servletRequest,servletResponse);
//
//    }
//
//    @Override
//    public void destroy() {
//
//    }
//}
